package com.atom.common.util;

import com.atom.common.CommonConstant;

public class UrlGenerateUtil {
  private static final boolean isFull = GlobalConfigReader.getBooleanValue(CommonConstant.URL_FULLMODE);
  private static final String HOST = isFull ? GlobalConfigReader.getStringValue(CommonConstant.HOST_SERVERNAME) : "";
  private static final String Separator = "/";  

  public static String getSaveUrl(String taskDefinitionKey, String processDefinitionKey) {
    return HOST + processDefinitionKey + Separator + "save" + Separator + taskDefinitionKey;
  }

  public static String getSubmitUrl(String taskDefinitionKey, String processDefinitionKey) {
    return HOST + processDefinitionKey + Separator + "submit" + Separator + taskDefinitionKey;
  }

  public static String getDeleteUrl(String taskDefinitionKey, String processDefinitionKey) {
    return HOST + processDefinitionKey + Separator + "delete";
  }

  public static String getCreateUrl(String taskDefinitionKey, String processDefinitionKey) {
    return HOST + processDefinitionKey + Separator + "create";
  }

  public static String getDetailUrl(String taskDefinitionKey, String processDefinitionKey, String taskId) {
    return HOST + processDefinitionKey + Separator + "detail" + Separator + taskDefinitionKey + Separator + taskId;
  }

  public static String getHistoryUrl(String processDefinitionKey, String taskId) {
    return HOST + processDefinitionKey + Separator + "history" + Separator + taskId;
  }

  public static String getDiagramUrl(String taskDefinitionKey, String processDefinitionKey, String mainProcessInstanceId) {
    return HOST + processDefinitionKey + Separator + "diagram" + Separator + mainProcessInstanceId;
  }

  public static String getLogUrl(String mainProcessInstanceId, String processDefinitionKey) {
    return HOST + processDefinitionKey + Separator +"log" + Separator + mainProcessInstanceId;
  }

  public static String getLockUrl(String taskId, String userId) {
    return HOST + "lock" + Separator + taskId + Separator + userId;
  }


}
